$(function(){
	//判断注册信息是否填写正取
	$("#submit").click(function(){
		var name = $("#name").val();
		var psd = $("#password").val();
		var num = $("#num").val();
		if(name==""){
			layer.open({
				type:0,
				time:1,
				content:'用户名不能为空！',
				skin:'msg',
				shade:'ture',
				anim:'false'
			});
			return false;
		};
		var nameTel = /^1[3|4|5|8][0-9]\d{4,8}$/;
		var nameEmail =  /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
		nameTel.test(name);
		if(!(nameTel.test(name)||nameEmail.test(name))){
			console.log("111")
			layer.open({
				type:0,
				time:1,
				content:'请填写正确格式！',
				skin:'msg',
				shade:'ture',
				anim:'false'
			});
			return false;
		}
		if(num==""){
			layer.open({
				type:0,
				time:1,
				content:'验证码不能为空！',
				skin:'msg',
				shade:'ture',
				anim:'false'
			});
			return false;
		};
		if(psd==""){
			layer.open({
				type:0,
				time:1,
				content:'密码不能为空！',
				skin:'msg',
				shade:'ture',
				anim:'false'
			});
			return false;
		};
		var passwordTip =/^[a-zA-Z]\w{5,17}$/;
		if(!passwordTip.test(psd)){
			layer.open({
				type:0,
				time:1,
				content:'密码格式不正确！',
				skin:'msg',
				shade:'ture',
				anim:'false'
			});
			return false;
		}
	});
	//选框点击切换状态
	$(".protocol i").click(function(){
		$(".protocol i").toggleClass("checked");
		isChecked();
	});
	//根据协议点击状态判断submit是否可以点击
	function isChecked(){
		var ischecked = $(".protocol i").hasClass("checked");
		if(!ischecked){
			$("#submit").attr("disabled","disabled");
			$("#submit").css({"background-color":"#888888"});
		}else{
			$("#submit").attr("disabled", false);
			$("#submit").css({"background-color":"#53A218"});
		};
	};
	isChecked();
});